const mongoose = require("./db");
//优惠券
const couponsSchema = mongoose.Schema({
   good:{
    type:mongoose.Types.ObjectId,
    ref:'good'
   },
   classid:{
    type:mongoose.Types.ObjectId,
    ref:'classify'
   },
   price:Number,
   type:String,
   done:Boolean,
   desc:String,
   num:Number
})
//用户有哪些优惠券
const userCouponsSchema = mongoose.Schema({
    uid:{
     type:mongoose.Types.ObjectId,
     ref:'user'
    },
    cid:{
        type:mongoose.Types.ObjectId,
        ref:'coupons'
    }
 })
const couponsModel = mongoose.model("coupons", couponsSchema, "coupons")
const userCouponsModel = mongoose.model("userCoupons", userCouponsSchema, "userCoupons")
module.exports = { couponsModel, userCouponsModel }